<template>
	<view>

		<button class="savabtn" @click="myupload" style="margin: 30rpx auto;">
			上传录音
		</button>
		<!-- <view v-for="i in classlist">
			<view class="mainbox u-p-30 u-m-t-30" >
				<view class="u-p-tb-20" >班级名称：{{i.className}}</view>
				<view class="mainboxitem flex-between">
					<view class="">
						<text>语言量</text>
						<text class="u-font-24 grey" >（全班平均数）</text>
					</view>
					<text class="grey">{{i.languageAmount}}字</text>
				</view>
				
				<view class="mainboxitem flex-between u-m-t-20">
					<view class="">
						<text>运动量</text>
						<text class="u-font-24 grey " >（全班平均数）</text>
					</view>
					<text class="grey">{{i.activityAmount}}步</text>
				</view>
			</view>
			
			
			<view class="u-p-30 mainbox">
				<text>饮食完成情况</text>
				<view class="u-m-tb-10 grey u-font-24">
					{{i.dietSituation}}
				</view>
				
			</view>
			
			<view class="u-p-30 mainbox">
				<text>能力发展方面</text>
				<view class="u-m-tb-10 grey u-font-24">
					{{i.abilityDirection}}
				</view>
				<!-- <view class="u-m-tb-10 grey u-font-24">
					能力2
				</view> -->


		<!-- <view class="u-p-30 mainbox ">
			<text>预警情况</text>
			<view class="u-m-tb-10 grey u-font-24">
				{{i.warning}}
			</view>

		</view> -->

		<!-- <u-empty v-if="classlist.length==0"></u-empty> -->
		<teachertabbar :value='2'></teachertabbar>
	</view>
</template>

<script>
	import teachertabbar from '../../components/teachertabbar.vue';
	export default {
		components: {
			teachertabbar
		},
		data() {
			return {
				classlist: []
			};
		},
		onShow() {
			this.init()
		},
		methods: {
			myupload() {
				let _this = this
				uni.chooseMessageFile({
					count: 1, //默认100
					extension: ['.m4a', '.mp3'], //根据文件拓展名过滤，每一项都不能是空字符串。默认不过滤。
					success: function(res) {
						var tempFilePaths = res.tempFiles;
						console.log(res)
						console.log(JSON.stringify(tempFilePaths));
						_this.saveRecord(tempFilePaths[0])
					}
				})
			},
			saveRecord(param) {
				uni.showLoading({
					title: '上传中',
					mask: true
				})
				uni.uploadFile({
					url: this.$uploadUrl, //仅为示例，非真实的接口地址
					filePath: param,
					name: 'file',
					formData: {
						'user': 'test'
					},
					header: {
						'Authorization': "Bearer " + uni.getStorageSync('token'),
					},
					success: (uploadFileRes) => {
						console.log(uploadFileRes.data);
						uni.hideLoading()
					}
				});
			},
			init() {
				this.$api.get('/assistant/xClass/studySituation', {}).then(res => {
					this.classlist = res.data
				})
			},
		}
	}
</script>

<style lang="scss">
	.mainbox {
		background-color: #fff;

		.grey {
			color: #9E9E9E;
		}
	}
</style>